home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume22 / auth / part01 next >
Encoding:
Internet Message Format  |  1990-04-29  |  53.8 KB

  1. Subject:  v22i001:  RFC 931 TCP Authentication server, Part01/02
  2. Newsgroups: comp.sources.unix
  3. Approved: rsalz@uunet.UU.NET
  4. X-Checksum-Snefru: 478415bf 1082bb14 40ecd74b ad50453c
  5.  
  6. Submitted-by: Dan Bernstein <brnstnd@acf10.nyu.edu>
  7. Posting-number: Volume 22, Issue 1
  8. Archive-name: auth2.1/part01
  9.  
  10. [  For more details, see rfc931 which is included in this package. --r$ ]
  11.  
  12. This package provides two benefits. The first is a secure user-level
  13. implementation of RFC 931, the Authentication Server; unless TCP itself
  14. is compromised, it is impossible to forge mail or news between computers
  15. supporting RFC 931. The second is a single, modular interface to TCP.
  16. Programs written to work with authtcp and attachport don't even need to
  17. be recompiled to run under a more comprehensive network security system
  18. like Kerberos, as long the auth package is replaced.
  19.  
  20. #! /bin/sh
  21. # This is a shell archive.  Remove anything before this line, then unpack
  22. # it by saving it into a file and typing "sh file".  To overwrite existing
  23. # files, type "sh file -c".  You can also feed this as standard input via
  24. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  25. # will see the following message at the end:
  26. #        "End of archive 1 (of 2)."
  27. # Contents:  CHANGES Makefile README attachport.man authd.c authd.man
  28. #   authtcp.man authuser.c authuser.h authuser.man dir.doc djbatoi.h
  29. #   djberr.h
  30. # Wrapped by rsalz@litchi.bbn.com on Mon Apr 30 15:53:39 1990
  31. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  32. if test -f 'CHANGES' -a "${1}" != "-c" ; then 
  33.   echo shar: Will not clobber existing file \"'CHANGES'\"
  34. else
  35. echo shar: Extracting \"'CHANGES'\" \(3686 characters\)
  36. sed "s/^X//" >'CHANGES' <<'END_OF_FILE'
  37. X4/18/90: Packaged auth 2.1 to replace previous comp.sources.unix submission.
  38. X4/18/90: authd version 2.1.
  39. X4/18/90: authd looks much prettier.
  40. X4/18/90: attachport version 4.1.
  41. X4/18/90: authd supports ! lock files.
  42. X4/18/90: attachport forks as real uid.
  43. X4/18/90: attachport now checks periodically for lost children.
  44. X4/18/90: Corrected locking scheme for exceptional (i.e. impossible) cases.
  45. X4/18/90: authtcp version 2.1.
  46. X4/18/90: authtcp forks as real uid.
  47. X4/18/90: attachport handles signals better.
  48. X4/18/90: authtcp handles signals better. It's annoying that extensions
  49. X     to the signal semantics could make secure programs insecure.
  50. X4/18/90: attachport is now just as careful.
  51. X4/18/90: authtcp is now ridiculously careful to switch to effective uid
  52. X     before unlinking lock file and to real uid before exiting.
  53. X4/18/90: Aargh, fork() uses effective uid rather than real uid for
  54. X     MAXUPRC checks. This ``feature'' can bring down attachport and
  55. X     authtcp if MAXUPRC is small and the machine is big.
  56. X
  57. X4/2/90: attachport version 4.0.
  58. X4/2/90: authtcp version 2.0.
  59. X4/2/90: authd version 2.0.
  60. X4/2/90: authuser version 2.0.
  61. X4/2/90: Final packaging and distribution for comp.sources.unix.
  62. X
  63. X4/2/90: Everything passes lint perfectly, though not lint -hacx.
  64. X
  65. X4/2/90: attachport now understands SIGTERM from killaport.
  66. X4/2/90: All programs now use inet_ntoa() where appropriate.
  67. X4/2/90: All programs now use isascii() where appropriate.
  68. X4/2/90: attachport now understands everything.
  69. X4/2/90: Integrated attachport into auth distribution. attachport CHANGES:
  70. X        3/21/90: Somehow attachport has gotten up to 3.6.
  71. X        1/28/90: Added -0 option to wither away when input file disappears.
  72. X        1/28/90: Added -1 option as a computer-friendly -v.
  73. X        1/7/90: attachport 3.5.
  74. X        Cleaned up mostly everything.
  75. X        attachport version 3.0, 11/1/89.
  76. X
  77. X4/1/90: authuser now checks for USERID from the Authentication Server,
  78. X    though it doesn't do anything informative upon a remote ERROR.
  79. X4/1/90: authd now uses unsigned where it should.
  80. X4/1/90: authuser now uses unsigned where it should.
  81. X4/1/90: authtcp now uses unsigned where it should.
  82. X4/1/90: authd now uses ctype.h appropriately.
  83. X
  84. X4/1/90: authd supports new locking protocol.
  85. X4/1/90: authtcp supports new locking protocol.
  86. X4/1/90: Set up new locking procedure to prevent authentication race
  87. X    condition; attachport will have to support this too.
  88. X
  89. X3/31/90: authtcp version 1.8.
  90. X
  91. X3/31/90: authtcp now talks to the remote authd.
  92. X3/31/90: authuser version 1.5.
  93. X3/31/90: Redid authuser interface.
  94. X3/31/90: Added authuser library to authtcpd (now just auth) distribution.
  95. X
  96. X3/27/90: authtcp now supports getservbyname()---and an interesting
  97. X     inconsistency showed up! Check sockaddr_in in netinet/in.h
  98. X     versus servent.s_port in netdb.h. Ho hum.
  99. X3/27/90: Touched up authtcp a bit.
  100. X
  101. X1/31/90: authd version 1.52.
  102. X1/31/90: authtcp version 1.52.
  103. X
  104. X1/31/90: authtcp now supports TSTP.
  105. X1/31/90: Both programs now have AUTHDIR ifdefed so it can go into Makefile.
  106. X
  107. XGetopt usage compatible with dumb getopt (no special numeric treatment).
  108. X
  109. X1/7/90: authd version 1.5.
  110. X1/7/90: authtcp version 1.5.
  111. X
  112. XBoth programs now use getopt.
  113. X
  114. Xauthd passes lint.
  115. X
  116. Xauthtcp: Whoops, really should turn off TSTP, as we don't handle stopping.
  117. X
  118. Xauthtcp keeps socket open, to close a Trojan Horse-like security hole.
  119. Xauthtcp doesn't turn off signals for its child.
  120. X
  121. Xauthtcp version 1.1, 11/1/89.
  122. X
  123. Xauthtcp has the verbose option it's been begging for.
  124. Xauthtcp now understands gethostbyname().
  125. X
  126. Xauthd version 1.001, 11/1/89.
  127. Xauthtcp version 1.001, 11/1/89.
  128. X
  129. XChanged 50 in both programs to be sizeof(AUTHDIR) + 30.
  130. X
  131. Xauthd version 1.0, 10/26/89.
  132. Xauthtcp version 1.0, 10/26/89.
  133. END_OF_FILE
  134. if test 3686 -ne `wc -c <'CHANGES'`; then
  135.     echo shar: \"'CHANGES'\" unpacked with wrong size!
  136. fi
  137. # end of 'CHANGES'
  138. fi
  139. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  140.   echo shar: Will not clobber existing file \"'Makefile'\"
  141. else
  142. echo shar: Extracting \"'Makefile'\" \(1570 characters\)
  143. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  144. XCC=cc
  145. XCCOPTS=-O
  146. XNROFF=nroff
  147. XNROFFOPTS=-man
  148. X
  149. X# -DAUTHDIR=\"directory\"  to override default of /usr/etc/auth
  150. X# -DAUTHTCPPORT=port  to override default of 113
  151. X# -DMAXHOSTNAMELEN=nn  to specify maximum host name length
  152. X#                      (default in sys/param.h, except on Suns)
  153. X
  154. Xdefault: all
  155. X
  156. Xall: attachport authtcp authd authuser.o attachport.1 authtcp.1 authd.8 authuser.3
  157. X
  158. Xshar: auth.shar
  159. X
  160. Xattachport: attachport.o authuser.o Makefile
  161. X    $(CC) $(CCOPTS) -o attachport attachport.o authuser.o
  162. X
  163. Xattachport.o: attachport.c authuser.h Makefile
  164. X    $(CC) $(CCOPTS) -c attachport.c
  165. X
  166. Xauthtcp: authtcp.o authuser.o Makefile
  167. X    $(CC) $(CCOPTS) -o authtcp authtcp.o authuser.o
  168. X
  169. Xauthtcp.o: authtcp.c authuser.h Makefile
  170. X    $(CC) $(CCOPTS) -c authtcp.c
  171. X
  172. Xauthd: authd.c Makefile
  173. X    $(CC) $(CCOPTS) -o authd authd.c
  174. X
  175. Xauthuser.o: authuser.c Makefile
  176. X    $(CC) $(CCOPTS) -c authuser.c
  177. X
  178. Xattachport.1: attachport.man Makefile
  179. X    $(NROFF) $(NROFFOPTS) < attachport.man > attachport.1
  180. X
  181. Xauthtcp.1: authtcp.man Makefile
  182. X    $(NROFF) $(NROFFOPTS) < authtcp.man > authtcp.1
  183. X
  184. Xauthd.8: authd.man Makefile
  185. X    $(NROFF) $(NROFFOPTS) < authd.man > authd.8
  186. X
  187. Xauthuser.3: authuser.man Makefile
  188. X    $(NROFF) $(NROFFOPTS) < authuser.man > authuser.3
  189. X
  190. Xauth.shar: CHANGES README attachport.man authtcp.man authd.man authuser.man Makefile attachport.c authtcp.c authd.c authuser.c authuser.h djberr.h djbatoi.h dir.doc rfc931
  191. X    shar CHANGES README attachport.man authtcp.man authd.man authuser.man Makefile attachport.c authtcp.c authd.c authuser.c authuser.h djberr.h djbatoi.h dir.doc rfc931 > auth.shar
  192. X    chmod 400 auth.shar
  193. END_OF_FILE
  194. if test 1570 -ne `wc -c <'Makefile'`; then
  195.     echo shar: \"'Makefile'\" unpacked with wrong size!
  196. fi
  197. # end of 'Makefile'
  198. fi
  199. if test -f 'README' -a "${1}" != "-c" ; then 
  200.   echo shar: Will not clobber existing file \"'README'\"
  201. else
  202. echo shar: Extracting \"'README'\" \(4153 characters\)
  203. sed "s/^X//" >'README' <<'END_OF_FILE'
  204. Xattachport - attach a server program to a TCP port
  205. Xauthtcp - create a locally authenticated TCP connection to an Internet host
  206. Xauthd - authentication server daemon
  207. Xauthuser - remote authentication library
  208. X
  209. XThis package provides two benefits. The first is a secure user-level
  210. Ximplementation of RFC 931, the Authentication Server; unless TCP itself
  211. Xis compromised, it is impossible to forge mail or news between computers
  212. Xsupporting RFC 931. The second is a single, modular interface to TCP.
  213. XPrograms written to work with authtcp and attachport don't even need to
  214. Xbe recompiled to run under a more comprehensive network security system
  215. Xlike Kerberos, as long the auth package is replaced.
  216. X
  217. Xattachport version 4.1, April 18, 1990.
  218. XCopyright (c) 1990, Daniel J. Bernstein.
  219. XAll rights reserved.
  220. X
  221. Xauthtcp version 2.1, April 18, 1990.
  222. XCopyright (c) 1990, Daniel J. Bernstein.
  223. XAll rights reserved.
  224. X
  225. Xauthd version 2.1, April 18, 1990.
  226. XCopyright (c) 1990, Daniel J. Bernstein.
  227. XAll rights reserved.
  228. X
  229. Xauthuser version 2.0, April 2, 1990.
  230. XCopyright (c) 1990, Daniel J. Bernstein
  231. XAll rights reserved.
  232. X
  233. XThis distribution packaged April 18, 1990.
  234. X
  235. XFiles:
  236. XCHANGES         Description of changes since first distributed version
  237. XREADME          This document
  238. XMakefile        Installation commands
  239. Xattachport.c    The attachport program
  240. Xauthtcp.c       The authtcp program
  241. Xauthd.c         The authd program
  242. Xauthuser.c      The authuser library
  243. Xattachport.man  Documentation
  244. Xauthtcp.man     Documentation
  245. Xauthd.man       Documentation
  246. Xauthuser.man    Documentation
  247. Xdjberr.h        Error macros
  248. Xdjbatoi.h       Replacement atoi()---Sun's library version can crash
  249. Xdir.doc         Description of authentication directory contents
  250. Xrfc931          RFC 931, Authentication Server
  251. X
  252. XEdit the options in Makefile and type make. attachport, authtcp, and
  253. Xauthd will be the executable programs; authuser.o will be the linkable
  254. Xlibrary; attachport.1, authtcp.1, authd.8, and authuser.3 will be the
  255. Xnroff'ed documentation.
  256. X
  257. XYou probably want to pick up the multitee and authutil packages before
  258. Xtrying out any of these programs.
  259. X
  260. XFor authentication to work, you must set up a new userid, say auth.
  261. XUid auth should not permit logins. Its encrypted password should be
  262. Xsomething impossible, like an asterisk. Its shell should be /bin/true.
  263. XIts home directory should be /nonexistent. Its uid should be unique.
  264. X
  265. Xauthtcp and attachport should be setuid auth; check the source carefully
  266. Xfor security holes! You also need a directory /usr/etc/auth/tcp, owner
  267. Xauth, group irrelevant, mode 0700. (You can use a different directory/tcp
  268. Xif you set AUTHDIR in the Makefile.)
  269. X
  270. Xauthd should be set up under attachport(1) or inetd(8) to receive
  271. Xconnections on TCP port 113. It should not be setuid auth, though it
  272. Xwill always run as auth.
  273. X
  274. XThe authuser library needs no particular preparation; if you want to
  275. Xmake it available to users, put it into a library archive and copy
  276. Xauthuser.h to /usr/include.
  277. X
  278. XI don't pretend to know your machine's setup so there's no make install.
  279. X
  280. XRead CHANGES for a list of changes. Type authtcp -C and authtcp -W
  281. Xfor copyright and warranty information, authtcp -H for help. Similarly
  282. Xfor attachport and authd. For authuser, print authusercopyright[] and
  283. Xauthuserwarranty[] for copyright and warranty information, authuserhelp[]
  284. Xfor help.
  285. X
  286. XRead dir.doc for a description of the authentication directory as used
  287. Xby authtcp, attachport, and authd. 
  288. X
  289. X  Some BSD variants (notably ULTRIX) handle multiple non-root setuid
  290. X  processes poorly. To test the behavior of your system, try the
  291. X  following sequence from a root csh:
  292. X      SU% cp /usr/bin/sleep /tmp/slip
  293. X      SU% chown nobody /tmp/slip; chmod 4755 /tmp/slip
  294. X      SU% repeat 100 sh -ic '(/tmp/slip 10000 &) 2>&1' > /tmp/pids
  295. X      SU% /bin/kill "`cat /tmp/pids`"
  296. X  Here 100 is any number bigger than MAXUPRC in /usr/include/sys/param.h.
  297. X  If the repeat fails, hangs, or crashes your system, complain at your
  298. X  vendor: you can't reliably install programs setuid to anything except
  299. X  root. In this case you'll have to install auth setuid root rather than
  300. X  setuid auth as per the instructions; this is perfectly safe.
  301. END_OF_FILE
  302. if test 4153 -ne `wc -c <'README'`; then
  303.     echo shar: \"'README'\" unpacked with wrong size!
  304. fi
  305. # end of 'README'
  306. fi
  307. if test -f 'attachport.man' -a "${1}" != "-c" ; then 
  308.   echo shar: Will not clobber existing file \"'attachport.man'\"
  309. else
  310. echo shar: Extracting \"'attachport.man'\" \(7625 characters\)
  311. sed "s/^X//" >'attachport.man' <<'END_OF_FILE'
  312. X.TH attachport 1
  313. X.SH NAME
  314. Xattachport \- attach a server program to a TCP port
  315. X.SH SYNTAX
  316. Xattachport
  317. X[
  318. X\fB\-ACHUVW\fI
  319. X] [
  320. X\fB\-01rRvxX\fI
  321. X] [
  322. X\fB\-p\fIportnum
  323. X]
  324. Xprogram
  325. X[
  326. Xarg ...
  327. X] &
  328. X.SH DESCRIPTION
  329. X.I attachport
  330. Xattaches a server to a TCP port.
  331. XThe port may be specified by
  332. X.I portnum,
  333. Xor one will be assigned;
  334. Xthe server is specified by
  335. X.I program.
  336. X.I attachport
  337. Xwill pass any further arguments through to the server program.
  338. X.PP
  339. X.I portnum
  340. Xcan be fully specified as a port number,
  341. Xor given as a service name.
  342. X.PP
  343. XAny incoming request on the TCP port
  344. Xinvokes a new copy of the server,
  345. Xwhich runs with all input directed from
  346. Xand output directed to the port.
  347. XAll environment variables and similar process data
  348. Xare taken directly from the original invocation of
  349. X.I attachport;
  350. Xhowever,
  351. X.I attachport
  352. Xwill attempt to dissociate itself from its controlling terminal.
  353. X.PP
  354. X.I attachport
  355. Xworks with
  356. Xthe Authentication Server,
  357. X.I authd(8):
  358. Xthe connecting host can verify the identity of the server.
  359. X.PP
  360. XOptions
  361. X.B ACHUVW
  362. Xprint the authorship notice,
  363. Xcopyright notice,
  364. Xhelp notice,
  365. Xshort usage summary,
  366. Xversion number,
  367. Xand warranty information respectively.
  368. X.PP
  369. X.I attachport
  370. Xhas several flags:
  371. X.TP 12
  372. X\fB\-p\fIportnum
  373. XAttempt to attach the server to port
  374. X.I portnum.
  375. XThe port number is restricted on most machines to a number between
  376. X0 and 65535; any larger number will be mapped down into this range.
  377. XPorts 0 through 1023 are generally restricted to root processes.
  378. XPorts above 50000 are a good choice for user (nonstandard) servers.
  379. XIf you do not specify a port,
  380. X.I attachport
  381. Xwill assign one.
  382. X.TP
  383. X\fB\-v\fI
  384. XVerbose:
  385. X.I attachport
  386. Xwill report success.
  387. X.TP
  388. X\fB\-1\fI
  389. XWrite the port number to standard output as an integer followed by
  390. Xa newline.
  391. XThis is the non-user-friendly version of
  392. X\fB\-v.
  393. X.TP
  394. X\fB\-0\fI
  395. XEvery ten seconds, check that the (otherwise unused) standard input
  396. Xfile still has links. If it doesn't,
  397. X.I attachport
  398. Xwill slowly wither away,
  399. Xdying as soon as its children have exited and cleaned up.
  400. X.I attachport
  401. Xwill refuse further connections on the same port in the meantime.
  402. XThis is appropriate for a shell script;
  403. Xuse
  404. X.I killaport(1)
  405. Xto kill
  406. X.I attachport
  407. Xmanually.
  408. X.TP
  409. X\fB\-x\fI
  410. XLocally authenticate each connection (default).
  411. X.TP
  412. X\fB\-X\fI
  413. XDo not locally authenticate connections.
  414. X.TP
  415. X\fB\-r\fI
  416. XAttempt to determine the identity of the other end of
  417. Xeach connection
  418. Xthrough the remote Authentication Server (default).
  419. X.I attachport
  420. Xwill place the identity
  421. Xinto environment variable
  422. XREMOTE, with the form
  423. X.I user@in.et.ad.dr
  424. Xwhere
  425. X.I user
  426. Xis a string giving the user name
  427. Xand
  428. X.I in.et.ad.dr
  429. Xis a numerical Internet address.
  430. XIf the other end is not authenticated,
  431. X.I user
  432. Xwill be blank.
  433. XNote that
  434. X.I user
  435. Xmay contain @ signs;
  436. XREMOTE should be parsed from
  437. Xright to left.
  438. X.I attachport
  439. Xalso sets environment variable
  440. XPROTO to the string
  441. X.I TCP.
  442. X.TP
  443. X\fB\-R\fI
  444. XDo not remotely authenticate.
  445. XThis is the default if the local port is 113 (auth):
  446. Xtwo machines caught in an Authentication Server loop
  447. Xwould rapidly be brought to their knees,
  448. Xthough the loop would end after user
  449. X.I auth
  450. Xhit its process limit on either machine.
  451. X.PP
  452. XThe server could use
  453. X.I getpeername(2)
  454. Xto find out who it's talking to,
  455. Xbut it's faster, simpler, and more portable
  456. Xto use PROTO and REMOTE.
  457. XFuture versions of
  458. X.I attachport,
  459. Xversions for other network interfaces,
  460. Xand versions for completely different communications systems
  461. Xwill all provide the same PROTO/REMOTE interface.
  462. XOf course, if PROTO is not TCP, REMOTE will probably
  463. Xhave a different format.
  464. X.PP
  465. XNote that the insertion of carriage returns after newlines
  466. Xis normally done automatically by the terminal driver.
  467. XYou must be careful to output carriage returns before newlines
  468. Xfor your program to talk correctly with a low-level communications server.
  469. X.PP
  470. XYou should make sure to run 
  471. X.I attachport
  472. Xin the background.
  473. XAlso, you should make sure that its diagnostic output goes
  474. Xeither into a log file or into /dev/null.
  475. X.SH DIAGNOSTICS
  476. X.TP 1.5i
  477. X\fIwarning: can't find my own Internet number?!\fB
  478. XYour host is not listed in your hosts table?!
  479. X.TP
  480. X.I cannot setreuid
  481. XThis should never happen.
  482. X.TP
  483. X.I cannot create socket
  484. XSomething went wrong in creating the communications socket.
  485. X.TP
  486. X.I cannot bind: Address already in use
  487. XSome other process is attached to that port.
  488. X(Note that even if that process goes away,
  489. Xit may be a few minutes before the port is free again.)
  490. X.TP
  491. X.I cannot bind: some other problem
  492. XYou can't bind the communications socket to the port for some
  493. Xother reason. Do you have permission for ports 0 through 1023?
  494. X.TP
  495. X.I cannot listen
  496. XSomething went wrong in setting up the socket to listen for
  497. Xincoming calls.
  498. X.TP
  499. X.I warning: cannot open /dev/tty
  500. X.I attachport
  501. Xwill not be able to dissociate itself from your terminal.
  502. XYou should get this warning if you invoke
  503. X.I attachport
  504. Xwithout a controlling terminal in the first place.
  505. X.TP
  506. X.I warning: cannot dissociate /dev/tty
  507. X.I attachport
  508. Xwill not be able to dissociate itself from your terminal.
  509. X.TP
  510. X.I cannot confirm connection
  511. X.I attachport
  512. Xis unable to access
  513. XTCP status information for the connection.
  514. XThis shouldn't happen;
  515. Xlet your system administrator
  516. Xand travel agent know if it does.
  517. X.TP
  518. X.I cannot allocate environment
  519. XThere's so little memory available that
  520. X.I attachport
  521. Xis unable to find space for
  522. Xthe REMOTE and PROTO environment variables.
  523. XIf REMOTE and PROTO are in the environment
  524. Xwhen
  525. X.I attachport
  526. Xstarts,
  527. Xthis can't happen,
  528. Xand
  529. X.I attachport
  530. Xwill run just a tiny bit faster.
  531. X(On the other hand, most other programs
  532. Xwill run a tiny bit slower.)
  533. X.TP
  534. X.I cannot get socket name
  535. XThis shouldn't happen.
  536. X.TP
  537. X.I local port locked
  538. X.I attachport
  539. Xis set up incorrectly.
  540. X.TP
  541. X.I attached to port nnnnn
  542. X.I attachport
  543. Xhas successfully attached itself to a port,
  544. Xand you specified
  545. X.B\-v.
  546. X.TP
  547. X.I cannot execute
  548. X.I attachport
  549. Xis unable to start the server.
  550. X.TP
  551. X.I local port locked
  552. X.I attachport
  553. Xis set up incorrectly.
  554. X.TP
  555. X.I warning: cannot unlink authentication entry
  556. XThis should never happen;
  557. Xif it does, report the problem to your system administrator
  558. Xand make sure the entry is removed.
  559. X.TP
  560. X.I warning: cannot authenticate
  561. X.I attachport
  562. Xis set up incorrectly.
  563. X.SH MACHINES
  564. X.I attachport
  565. Xhas been tested on a VAX 8700 running ULTRIX 2.0,
  566. Xa Sun 3 running SunOS,
  567. Xa Sun 4 running SunOS,
  568. Xa Convex C-210 running Convex UNIX,
  569. Xan Astronautics ZS-2 running ZSUnix,
  570. Xand several other machines.
  571. X.SH FILES
  572. XNone.
  573. X.SH BUGS
  574. XNone known.
  575. X.SH RESTRICTIONS
  576. X.I attachport
  577. Xdoes not let you easily specify a pipeline or other sequence
  578. Xof commands; you must first set up an executable shell script
  579. Xthat does the desired combination of actions.
  580. X.PP
  581. X.I attachport
  582. Xdeals correctly but rigidly with multihomed hosts.
  583. X.PP
  584. X.I attachport
  585. Xdoes not support
  586. X.I syslog.
  587. X.PP
  588. XBecause of failures in the signal handling semantics,
  589. X.I attachport
  590. Xmay fail to notice a child exiting if too many children
  591. Xexit at once. Normally this doesn't matter, but if
  592. X.I attachport
  593. Xis withering away under
  594. X.B\-1
  595. Xor
  596. X.I killaport,
  597. Xit may stick around waiting for nothing.
  598. X.I attachport
  599. Xchecks for this condition and corrects it periodically.
  600. X.PP
  601. XIf
  602. X.I program
  603. Xforks and exits,
  604. Xpassing the connection to its children,
  605. Xit will lose authentication.
  606. XThis is consistent with other network programs and
  607. Xwith common sense: it's impossible to define
  608. X``the'' user on the other side of the connection if
  609. Xseveral processes, all with different uids, have that
  610. Xconnection open.
  611. X.SH VERSION
  612. Xattachport version 4.1, dated April 18, 1990.
  613. X.SH AUTHOR
  614. XCopyright 1990, Daniel J. Bernstein.
  615. X.SH "SEE ALSO"
  616. Xauthtcp(1),
  617. Xkillaport(1),
  618. Xtelnet(1),
  619. Xauthuser(3),
  620. Xgetservbyname(3),
  621. Xauthd(8),
  622. Xinetd(8)
  623. END_OF_FILE
  624. if test 7625 -ne `wc -c <'attachport.man'`; then
  625.     echo shar: \"'attachport.man'\" unpacked with wrong size!
  626. fi
  627. # end of 'attachport.man'
  628. fi
  629. if test -f 'authd.c' -a "${1}" != "-c" ; then 
  630.   echo shar: Will not clobber existing file \"'authd.c'\"
  631. else
  632. echo shar: Extracting \"'authd.c'\" \(6057 characters\)
  633. sed "s/^X//" >'authd.c' <<'END_OF_FILE'
  634. X/*
  635. Xauthd.c: Authentication Server daemon
  636. X*/
  637. X
  638. Xstatic char authdauthor[] =
  639. X"authd was written by Daniel J. Bernstein.\n\
  640. XInternet address: brnstnd@acf10.nyu.edu.\n";
  641. X
  642. Xstatic char authdversion[] = 
  643. X"authd version 2.1, April 18, 1990.\n\
  644. XCopyright (c) 1990, Daniel J. Bernstein.\n\
  645. XAll rights reserved.\n";
  646. X
  647. Xstatic char authdcopyright[] =
  648. X"authd version 2.1, April 18, 1990.\n\
  649. XCopyright (c) 1990, Daniel J. Bernstein.\n\
  650. XAll rights reserved.\n\
  651. X\n\
  652. XUntil January 1, 1995, you are granted the following rights: A. To make\n\
  653. Xcopies of this work in original form, so long as (1) the copies are exact\n\
  654. Xand complete; (2) the copies include the copyright notice, this paragraph,\n\
  655. Xand the disclaimer of warranty in their entirety. B. To distribute this\n\
  656. Xwork, or copies made under the provisions above, so long as (1) this is\n\
  657. Xthe original work and not a derivative form; (2) you do not charge a fee\n\
  658. Xfor copying or for distribution; (3) you ensure that the distributed form\n\
  659. Xincludes the copyright notice, this paragraph, and the disclaimer of\n\
  660. Xwarranty in their entirety. These rights are temporary and revocable upon\n\
  661. Xwritten, oral, or other notice by Daniel J. Bernstein. These rights are\n\
  662. Xautomatically revoked on January 1, 1995. This copyright notice shall be\n\
  663. Xgoverned by the laws of the state of New York.\n\
  664. X\n\
  665. XIf you have questions about authd or about this copyright notice,\n\
  666. Xor if you would like additional rights beyond those granted above,\n\
  667. Xplease feel free to contact the author at brnstnd@acf10.nyu.edu\n\
  668. Xon the Internet.\n";
  669. X
  670. Xstatic char authdwarranty[] =
  671. X"To the extent permitted by applicable law, Daniel J. Bernstein disclaims\n\
  672. Xall warranties, explicit or implied, including but not limited to the\n\
  673. Ximplied warranties of merchantability and fitness for a particular purpose.\n\
  674. XDaniel J. Bernstein is not and shall not be liable for any damages,\n\
  675. Xincidental or consequential, arising from the use of this program, even\n\
  676. Xif you inform him of the possibility of such damages. This disclaimer\n\
  677. Xshall be governed by the laws of the state of New York.\n\
  678. X\n\
  679. XIn other words, use this program at your own risk.\n\
  680. X\n\
  681. XIf you have questions about authd or about this disclaimer of warranty,\n\
  682. Xplease feel free to contact the author at brnstnd@acf10.nyu.edu\n\
  683. Xon the Internet.\n";
  684. X
  685. Xstatic char authdusage[] =
  686. X"Usage: authd [ -ACHUVW ] \n\
  687. XHelp:  authd -H\n";
  688. X
  689. Xstatic char authdhelp[] =
  690. X"authd provides TCP authentication information to other Internet hosts. \n\
  691. X\n\
  692. Xauthd -A: print authorship notice\n\
  693. Xauthd -C: print copyright notice\n\
  694. Xauthd -H: print this notice\n\
  695. Xauthd -U: print short usage summary\n\
  696. Xauthd -V: print version number\n\
  697. Xauthd -W: print disclaimer of warranty\n\
  698. X\n\
  699. Xauthd: provide authentication information as per RFC 931\n\
  700. X\n\
  701. Xauthd should be run under a TCP connection server, such as\n\
  702. Xinetd(8) or attachport(1).\n\
  703. X\n\
  704. XIf you have questions about or suggestions for authd, please feel free\n\
  705. Xto contact the author, Daniel J. Bernstein, at brnstnd@acf10.nyu.edu\n\
  706. Xon the Internet.\n";
  707. X
  708. X#include <stdio.h>
  709. Xextern int errno;
  710. X#include <sys/types.h>
  711. X#include <netinet/in.h>
  712. X#include <sys/file.h>
  713. X#ifdef BSD
  714. X#include <limits.h>
  715. X#endif
  716. Xextern int getopt();
  717. Xextern char *optarg; /* these should be in getopt.h! */
  718. Xextern int optind;
  719. X#include <ctype.h>
  720. X#include "djberr.h"
  721. X
  722. X#ifndef AUTHDIR
  723. X#define AUTHDIR "/usr/etc/auth"
  724. X#endif
  725. X
  726. X#define ERR(num) { printf("%s, %s: ERROR: UNKNOWN-ERROR\r\n",\
  727. X                          localport,remoteport); exit(num); }
  728. X
  729. Xmain(argc,argv,envp)
  730. Xint argc;
  731. Xchar *argv[];
  732. Xchar *envp[];
  733. X{
  734. X int ch;
  735. X char localport[10];
  736. X int localportlen = 0;
  737. X char remoteport[10];
  738. X int remoteportlen = 0;
  739. X int loop = 0;
  740. X struct sockaddr_in sa;
  741. X int salen;
  742. X int authfd;
  743. X char authfn[sizeof(AUTHDIR) + 30];
  744. X int lockfd;
  745. X char lockfn[sizeof(AUTHDIR) + 30]; /* for new locking protocol */
  746. X char lockbuf[32]; /* 5 pid, 1 :, 10 I, 1 ., 5 R, 1 \n, 8 U, 1 \0 */
  747. X unsigned long lockin;
  748. X unsigned short lockport;
  749. X int r;
  750. X char buf[9];
  751. X int opt;
  752. X
  753. X while ((opt = getopt(argc,argv,"ACHUVW")) != EOF)
  754. X   switch(opt)
  755. X    {
  756. X     case 'A': (void) err(authdauthor); exit(1);
  757. X     case 'C': (void) err(authdcopyright); exit(1);
  758. X     case 'H': (void) err(authdhelp); exit(1);
  759. X     case 'U': (void) err(authdusage); exit(1);
  760. X     case 'V': (void) err(authdversion); exit(1);
  761. X     case 'W': (void) err(authdwarranty); exit(1);
  762. X     case '?': (void) err(authdusage); exit(1);
  763. X    }
  764. X argv += optind, argc -= optind;
  765. X if (*argv)
  766. X  {
  767. X   (void) err(authdusage); exit(1);
  768. X  }
  769. X
  770. X while ((ch = getchar()) != ',')
  771. X  {
  772. X   if (isascii(ch) && isdigit(ch))
  773. X     localport[localportlen++] = ch;
  774. X   if (localportlen == 6) /* tough luck! */
  775. X     exit(2);
  776. X   if ((++loop) > 1000) /* tough luck! */
  777. X     exit(3);
  778. X  }
  779. X while ((ch = getchar()) != '\n')
  780. X  {
  781. X   if (isascii(ch) && isdigit(ch))
  782. X     remoteport[remoteportlen++] = ch;
  783. X   if (remoteportlen == 6) /* tough luck! */
  784. X     exit(4);
  785. X   if ((++loop) > 1000) /* tough luck! */
  786. X     exit(5);
  787. X  }
  788. X /* Now we'll be nice enough to respond. */
  789. X
  790. X salen = sizeof(sa);
  791. X if (getpeername(0,&sa,&salen) == -1) ERR(6)
  792. X
  793. X /* Now we have enough information to look up answer. */
  794. X
  795. X (void) sprintf(lockfn,"%s/tcp/lock.%s",AUTHDIR,localport);
  796. X if ((lockfd = open(lockfn,O_RDONLY)) == -1) ERR(7)
  797. X (void) flock(lockfd,LOCK_EX); /* can't fail */
  798. X if ((r = read(lockfd,lockbuf,31)) <= 0) ERR(8)
  799. X lockbuf[r] = '\0';
  800. X if (lockbuf[0] == '!') ERR(12) /* ding ding ding! security alert! */
  801. X
  802. X (void) sprintf(authfn,"%s/tcp/%D.%s.%s",AUTHDIR,sa.sin_addr.s_addr,
  803. X                localport,remoteport);
  804. X if ((authfd = open(authfn,O_RDONLY)) == -1)
  805. X  {
  806. X   /* maybe it's authtcp and username file isn't there yet */
  807. X   if (sscanf(lockbuf,"%*d:%D.%hd %8s",&lockin,&lockport,buf) < 3) ERR(9)
  808. X   if ((lockin != sa.sin_addr.s_addr) || (lockport != atoi(remoteport))) ERR(10)
  809. X   /* bingo! */
  810. X  }
  811. X else
  812. X  {
  813. X   if ((r = read(authfd,buf,8)) <= 0) ERR(11)
  814. X   buf[r] = '\0';
  815. X  }
  816. X
  817. X printf("%s, %s: USERID: UNIX: %s\r\n",localport,remoteport,buf);
  818. X
  819. X (void) flock(lockfd,LOCK_UN); /* unnecessary */
  820. X exit(0);
  821. X}
  822. END_OF_FILE
  823. if test 6057 -ne `wc -c <'authd.c'`; then
  824.     echo shar: \"'authd.c'\" unpacked with wrong size!
  825. fi
  826. # end of 'authd.c'
  827. fi
  828. if test -f 'authd.man' -a "${1}" != "-c" ; then 
  829.   echo shar: Will not clobber existing file \"'authd.man'\"
  830. else
  831. echo shar: Extracting \"'authd.man'\" \(2244 characters\)
  832. sed "s/^X//" >'authd.man' <<'END_OF_FILE'
  833. X.TH authd 8
  834. X.SH NAME
  835. Xauthd \- Authentication Server daemon
  836. X.SH SYNTAX
  837. Xauthd
  838. X[
  839. X\fB\-ACHUVW\fI
  840. X]
  841. X.SH DESCRIPTION
  842. X.I authd
  843. Xis a simple daemon implementing the
  844. XRFC 931 Authentication Server protocol.
  845. XIt should be invoked by a network server,
  846. Xsuch as
  847. X.I attachport(1),
  848. Xfor connections to TCP port 113.
  849. X.PP
  850. XThe client host
  851. Xgives
  852. X.I authd
  853. Xtwo numbers separated by a comma.
  854. X.I authd
  855. Xinterprets the numbers as TCP port numbers
  856. Xfor the local and remote sides respectively
  857. Xof a TCP connection between this host and the client host.
  858. XIt returns a line of the form
  859. X.EX
  860. Xlocalport, remoteport: USERID: UNIX: username
  861. X.EE
  862. Xwhere username
  863. Xis the name of the user on this side of
  864. Xthe specified connection.
  865. XIf
  866. X.I authd
  867. Xdoes not have an authentication entry for that connection,
  868. Xit returns a line of the form
  869. X.EX
  870. Xlocalport, remoteport: ERROR: UNKNOWN-ERROR.
  871. X.EE
  872. X.PP
  873. XOptions
  874. X.B ACHUVW
  875. Xprint the authorship notice,
  876. Xcopyright notice,
  877. Xhelp notice,
  878. Xshort usage summary,
  879. Xversion number,
  880. Xand warranty information respectively.
  881. X.PP
  882. X.SH DIAGNOSTICS
  883. X.TP
  884. XNone.
  885. X.SH MACHINES
  886. X.I authd
  887. Xhas been tested
  888. Xon an Astronautics ZS-2
  889. Xrunning ZSUnix,
  890. Xa Sun 3 running SunOS,
  891. Xa Sun 4 running SunOS,
  892. Xa Convex C-210 running Convex UNIX,
  893. Xand several other machines.
  894. X.SH FILES
  895. X/usr/etc/auth/tcp/*
  896. X.SH BUGS
  897. XNone known.
  898. X.SH RESTRICTIONS
  899. X.I authd
  900. Xdoes not require kernel support;
  901. Xit must be supported on the user level by
  902. X.I authtcp
  903. Xand
  904. X.I attachport.
  905. XIf those programs are not used,
  906. X.I authd
  907. Xis useless.
  908. X.PP
  909. XThe author feels quite confident in predicting that
  910. Xthe first problems people have with
  911. X.I authd
  912. Xwill be on multihomed hosts.
  913. XProgrammers be warned: It takes some effort
  914. Xto correctly use
  915. X.I authd
  916. Xon a multihomed host!
  917. X.SH VERSION
  918. Xauthd version 2.1, dated April 18, 1990.
  919. X.SH AUTHOR
  920. XCopyright 1990, Daniel J. Bernstein.
  921. X.SH REFERENCES
  922. XThe authentication server is more secure than passwords
  923. Xin some ways, but less secure than passwords in many ways.
  924. X(It's certainly better than no password at all---e.g., for
  925. Xmail or news.)
  926. XIt is not the final solution.
  927. XFor an excellent discussion of security problems within
  928. Xthe TCP/IP protocol suite, see
  929. XSteve Bellovin's article
  930. X``Security Problems in the TCP/IP Protocol Suite.''
  931. X.SH "SEE ALSO"
  932. Xauthtcp(1),
  933. Xattachport(1),
  934. Xauthuser(3),
  935. Xtcp(4),
  936. Xinetd(8)
  937. END_OF_FILE
  938. if test 2244 -ne `wc -c <'authd.man'`; then
  939.     echo shar: \"'authd.man'\" unpacked with wrong size!
  940. fi
  941. # end of 'authd.man'
  942. fi
  943. if test -f 'authtcp.man' -a "${1}" != "-c" ; then 
  944.   echo shar: Will not clobber existing file \"'authtcp.man'\"
  945. else
  946. echo shar: Extracting \"'authtcp.man'\" \(6629 characters\)
  947. sed "s/^X//" >'authtcp.man' <<'END_OF_FILE'
  948. X.TH authtcp 1
  949. X.SH NAME
  950. Xauthtcp \- create a locally authenticated TCP connection
  951. X.SH SYNTAX
  952. Xauthtcp
  953. X[
  954. X\fB\-d\fIn
  955. X] [
  956. X\fB\-p\fIlocalport
  957. X] [
  958. X\fB\-rRxXv\fI
  959. X] [
  960. X\fB\-ACHUVW\fI
  961. X]
  962. X\fIinetaddr\fB
  963. X\fItcpport\fB
  964. X\fIprogram\fB
  965. X[
  966. X\fIarg ...\fB
  967. X]
  968. X.SH DESCRIPTION
  969. X.I authtcp
  970. Xcreates a TCP connection to Internet host
  971. X\fIinetaddr\fB
  972. Xat port
  973. X\fItcpport\fB,
  974. Xthen runs
  975. X\fIprogram\fB
  976. Xwith the specified
  977. Xarguments.
  978. XThe local TCP port may be given as
  979. X\fIlocalport\fB,
  980. Xor
  981. X.I authtcp
  982. Xwill assign one.
  983. X.PP
  984. XUntil
  985. X.I program
  986. Xexits,
  987. X.I authd(8)
  988. Xwill report that the user owns the TCP connection.
  989. XHence the other end of the connection can
  990. Xverify the identity of this end,
  991. Xmodulo the lack of Internet security.
  992. X.PP
  993. X.I inetaddr
  994. Xcan be fully specified as a dotted Internet address,
  995. Xor given as a domain name.
  996. X.I tcpport
  997. Xcan be fully specified as a decimal port number,
  998. Xor given as a service name.
  999. X.PP
  1000. X.I authtcp
  1001. Xmakes the connection available
  1002. Xto 
  1003. X.I program
  1004. Xas a socket in file descriptor 6,
  1005. Xleaving all other file descriptors intact.
  1006. X.PP
  1007. XOptions
  1008. X.B ACHUVW
  1009. Xprint the authorship notice,
  1010. Xcopyright notice,
  1011. Xhelp notice,
  1012. Xshort usage summary,
  1013. Xversion number,
  1014. Xand warranty information respectively.
  1015. X.PP
  1016. X.I authtcp
  1017. Xhas several flags:
  1018. X.TP 12
  1019. X\fB\-d\fIn
  1020. XProvide the connection in file descriptor
  1021. X\fIn\fB,
  1022. Xrather than the default descriptor, 6.
  1023. XIf 
  1024. X\fIn\fB
  1025. Xis not specified,
  1026. X.I authtcp
  1027. Xwill open the connection in the first available file descriptor
  1028. Xand pass that number in place of the first argument to
  1029. X.I program
  1030. Xthat contains solely an equals sign (if there is one).
  1031. X.TP
  1032. X\fB\-p\fIlocalport
  1033. XAttempt to use
  1034. X.I localport
  1035. Xas the local TCP port number.
  1036. XThis may fail if that port number is out of
  1037. Xrange (usually 1\-65535),
  1038. Xor if another process is using that port
  1039. X(or has used it very recently).
  1040. XPorts 1 through 1023 are generally reserved for root processes,
  1041. Xand ports above 50000 are generally reserved for user servers.
  1042. XIf you specify
  1043. X.B \-p0
  1044. X(default),
  1045. X.I authtcp
  1046. Xwill assign a number.
  1047. XSeveral instances of
  1048. X.B \-p
  1049. Xdefer to the last.
  1050. X.TP
  1051. X\fB\-X\fI
  1052. XDo not attempt to locally authenticate the connection;
  1053. Xjust set up the connection and run
  1054. X.I program.
  1055. X.TP
  1056. X\fB\-x\fI
  1057. XLocally authenticate the connection (default).
  1058. X.TP
  1059. X\fB\-r\fI
  1060. XAttempt to determine the identity of the other end of
  1061. Xthis connection
  1062. Xthrough the remote Authentication Server (default).
  1063. X.I authtcp
  1064. Xwill place the identity
  1065. Xinto environment variable
  1066. XREMOTE, with the form
  1067. X.I user@in.et.ad.dr
  1068. Xwhere
  1069. X.I user
  1070. Xis a string giving the user name
  1071. Xand
  1072. X.I in.et.ad.dr
  1073. Xis a numerical Internet address.
  1074. XIf the other end is not authenticated,
  1075. X.I user
  1076. Xwill be blank.
  1077. XNote that
  1078. X.I user
  1079. Xmay contain @ signs;
  1080. XREMOTE should be parsed from
  1081. Xright to left.
  1082. X.I authtcp
  1083. Xalso sets environment variable
  1084. XPROTO to the string
  1085. X.I TCP.
  1086. X.TP
  1087. X\fB\-R\fI
  1088. XDo not remotely authenticate.
  1089. X.TP
  1090. X\fB\-v\fI
  1091. XVerbose: Print a message when the connection is established.
  1092. XAlso, report unusual termination of
  1093. X.I program.
  1094. X.PP
  1095. XIf
  1096. X.I program
  1097. Xterminates normally,
  1098. X.I authtcp
  1099. Xwill terminate with the same exit code.
  1100. XOtherwise it will terminate with exit code 1.
  1101. X.PP
  1102. X.SH DIAGNOSTICS
  1103. X.TP
  1104. X.I do not understand inetaddr
  1105. XYou probably specified a domain name address
  1106. Xthat
  1107. X.I authtcp
  1108. Xcan't decode.
  1109. X.TP
  1110. X.I cannot execute
  1111. X.I authtcp
  1112. Xis unable to execute
  1113. X.I program.
  1114. X.TP
  1115. X.I cannot unlink authentication entry
  1116. XThis should never happen; if it does,
  1117. Xreport the problem to your system administrator and
  1118. Xmake sure the entry is removed.
  1119. X.TP
  1120. X.I cannot bind local port
  1121. XYou probably specified a protected or out-of-range
  1122. Xport with
  1123. X.I\-p.
  1124. XIf you didn't specify
  1125. X.I\-p
  1126. Xand this message appears without a number,
  1127. Xall TCP ports are in use.
  1128. XReport this to your system administrator.
  1129. X.TP
  1130. X.I cannot confirm connection
  1131. X.I authtcp
  1132. Xis unable to access
  1133. XTCP status information for the connection.
  1134. XThis shouldn't happen;
  1135. Xlet your system administrator
  1136. Xand travel agent know if it does.
  1137. X.TP
  1138. X.I cannot allocate environment
  1139. XThere's so little memory available that
  1140. X.I authtcp
  1141. Xis unable to find space for
  1142. Xthe REMOTE and PROTO environment variables.
  1143. XIf REMOTE and PROTO are in the environment
  1144. Xwhen
  1145. X.I authtcp
  1146. Xstarts,
  1147. Xthis can't happen,
  1148. Xand
  1149. X.I authtcp
  1150. Xwill run just a tiny bit faster.
  1151. X(On the other hand, most other programs
  1152. Xwill run a tiny bit slower.)
  1153. X.TP
  1154. X.I cannot connect
  1155. XSelf-explanatory.
  1156. X.TP
  1157. X.I connected to
  1158. XSelf-explanatory.
  1159. X.TP
  1160. X.I killed by signal
  1161. XSelf-explanatory.
  1162. X.TP
  1163. X.I cannot authenticate
  1164. X.I authtcp
  1165. Xis not set up correctly.
  1166. X.TP
  1167. X.I local port locked
  1168. X.I authtcp
  1169. Xis not set up correctly.
  1170. X.TP
  1171. X.I cannot setreuid
  1172. XThis should never happen.
  1173. X.TP
  1174. X.I cannot create socket
  1175. XThis shouldn't happen, unless you have too many files open.
  1176. X.TP
  1177. X.I cannot use file descriptor
  1178. XThis should never happen.
  1179. X.TP
  1180. X.I cannot get socket name
  1181. XThis shouldn't happen.
  1182. X.SH MACHINES
  1183. X.I authtcp
  1184. Xhas been tested
  1185. Xon an Astronautics ZS-2
  1186. Xrunning ZSUnix,
  1187. Xa Sun 3 running SunOS,
  1188. Xa Sun 4 running SunOS,
  1189. Xa Convex C-210 running Convex UNIX,
  1190. Xand several other machines.
  1191. X.SH FILES
  1192. X/usr/etc/auth/tcp/*
  1193. X.SH BUGS
  1194. XNone known.
  1195. X.SH RESTRICTIONS
  1196. XIf
  1197. X.I program
  1198. Xcloses the connection long before exiting,
  1199. Xanother user can with a little effort make the same connection
  1200. Xand pretend to be the user running
  1201. X.I authtcp.
  1202. XHence
  1203. X.I program
  1204. Xshould exit soon after
  1205. Xclosing the connection.
  1206. X(Within several seconds is usually good enough.)
  1207. XA slightly more subtle
  1208. Xsecurity problem is that a program may set up a connection
  1209. Xunder
  1210. X.I authtcp,
  1211. Xbreak the connection without exiting,
  1212. Xand wait for a victim program to make the same connection.
  1213. XIf the attacker chose the correct local port number,
  1214. Xthere are two possibilities: Either the victim uses
  1215. Xthe authentication mechanism and will fail to connect,
  1216. Xor the victim does not understand the mechanism and will
  1217. Xbe misrepresented by
  1218. X.I authd.
  1219. XAs of version 1.5,
  1220. X.I authtcp
  1221. Xcloses both of these holes,
  1222. Xby keeping the connection open until
  1223. X.I program
  1224. Xexits.
  1225. XHence
  1226. X.I program
  1227. Xmust not depend upon the connection being closed
  1228. Xbefore it exits.
  1229. X.PP
  1230. X.I authtcp's
  1231. Xmost important function is to create a locally authenticated
  1232. Xconnection; remote authentication is useful but can be
  1233. Xperformed by
  1234. X.I program.
  1235. XIt is sometimes difficult to explain that the
  1236. X.I auth
  1237. Xin
  1238. X.I authtcp
  1239. Xstands for local, not remote, authentication.
  1240. X.PP
  1241. XIf
  1242. X.I gethostbyname(3)
  1243. Xdoesn't understand the Domain Name Server,
  1244. X.I authtcp
  1245. Xwon't either.
  1246. X.PP
  1247. X.I authtcp
  1248. Xshould try all the possible addresses returned
  1249. Xby
  1250. X.I gethostbyname(3);
  1251. Xit only tries the first.
  1252. X.PP
  1253. XIf
  1254. X.I program
  1255. Xpasses the connection to another
  1256. Xprocess and exits,
  1257. Xauthentication will be lost.
  1258. X.SH VERSION
  1259. Xauthtcp version 2.1, dated April 18, 1990.
  1260. X.SH AUTHOR
  1261. XCopyright 1990, Daniel J. Bernstein.
  1262. X.SH "SEE ALSO"
  1263. Xattachport(1),
  1264. Xauthuser(3),
  1265. Xtcp(4),
  1266. Xauthd(8),
  1267. Xgethostbyname(3),
  1268. Xgetservbyname(3)
  1269. END_OF_FILE
  1270. if test 6629 -ne `wc -c <'authtcp.man'`; then
  1271.     echo shar: \"'authtcp.man'\" unpacked with wrong size!
  1272. fi
  1273. # end of 'authtcp.man'
  1274. fi
  1275. if test -f 'authuser.c' -a "${1}" != "-c" ; then 
  1276.   echo shar: Will not clobber existing file \"'authuser.c'\"
  1277. else
  1278. echo shar: Extracting \"'authuser.c'\" \(6556 characters\)
  1279. sed "s/^X//" >'authuser.c' <<'END_OF_FILE'
  1280. Xchar authuserauthor[] =
  1281. X"authuser was written by Daniel J. Bernstein.\n\
  1282. XInternet address: brnstnd@acf10.nyu.edu.\n";
  1283. X
  1284. Xchar authuserversion[] = 
  1285. X"authuser version 2.0, April 2, 1990.\n\
  1286. XCopyright (c) 1990, Daniel J. Bernstein.\n\
  1287. XAll rights reserved.\n";
  1288. X
  1289. Xchar authusercopyright[] =
  1290. X"authuser version 2.0, April 2, 1990.\n\
  1291. XCopyright (c) 1990, Daniel J. Bernstein.\n\
  1292. XAll rights reserved.\n\
  1293. X\n\
  1294. XUntil January 1, 1993, you are granted the following rights: A. To make\n\
  1295. Xcopies of this work in original form, so long as (1) the copies are exact\n\
  1296. Xand complete; (2) the copies include the copyright notice, this paragraph,\n\
  1297. Xand the disclaimer of warranty in their entirety. B. To distribute this\n\
  1298. Xwork, or copies made under the provisions above, so long as (1) this is\n\
  1299. Xthe original work and not a derivative form; (2) you do not charge a fee\n\
  1300. Xfor copying or for distribution; (3) you ensure that the distributed form\n\
  1301. Xincludes the copyright notice, this paragraph, and the disclaimer of\n\
  1302. Xwarranty in their entirety. These rights are temporary and revocable upon\n\
  1303. Xwritten, oral, or other notice by Daniel J. Bernstein. These rights are\n\
  1304. Xautomatically revoked on January 1, 1993. This copyright notice shall be\n\
  1305. Xgoverned by the laws of the state of New York.\n\
  1306. X\n\
  1307. XIf you have questions about authuser or about this copyright notice,\n\
  1308. Xor if you would like additional rights beyond those granted above,\n\
  1309. Xplease feel free to contact the author at brnstnd@acf10.nyu.edu\n\
  1310. Xon the Internet.\n";
  1311. X
  1312. Xchar authuserwarranty[] =
  1313. X"To the extent permitted by applicable law, Daniel J. Bernstein disclaims\n\
  1314. Xall warranties, explicit or implied, including but not limited to the\n\
  1315. Ximplied warranties of merchantability and fitness for a particular purpose.\n\
  1316. XDaniel J. Bernstein is not and shall not be liable for any damages,\n\
  1317. Xincidental or consequential, arising from the use of this program, even\n\
  1318. Xif you inform him of the possibility of such damages. This disclaimer\n\
  1319. Xshall be governed by the laws of the state of New York.\n\
  1320. X\n\
  1321. XIn other words, use this program at your own risk.\n\
  1322. X\n\
  1323. XIf you have questions about authuser or about this disclaimer of warranty,\n\
  1324. Xplease feel free to contact the author at brnstnd@acf10.nyu.edu\n\
  1325. Xon the Internet.\n";
  1326. X
  1327. Xchar authuserhelp[] =
  1328. X"#include \"authuser.h\"\n\
  1329. X\n\
  1330. Xint auth_casecmp(u,v); char *u; char *v;\n\
  1331. XReturns 0 if strings are equal, 1 if the first is larger, -1 if the\n\
  1332. Xsecond is larger. Case is ignored.\n\
  1333. X\n\
  1334. Xchar *auth_xline(user,fd,&in);\n\
  1335. XReturns line like X-Auth-User: username or X-Forgery-By: username,\n\
  1336. Xdepending what the host on the other side of fd thinks of the user.\n\
  1337. X\n\
  1338. Xint auth_fd(fd,&in,&local,&remote);\n\
  1339. XPlaces address information for TCP connection fd into in, local, remote.\n\
  1340. X\n\
  1341. Xchar *auth_tcpuser(in,local,remote);\n\
  1342. XReturns name of user on remote@in side of local TCP connection.\n\
  1343. X\n\
  1344. Xchar *user; int fd; unsigned long in; unsigned short local, remote;\n\
  1345. X\n\
  1346. XIf you have questions about or suggestions for authuser, please feel free\n\
  1347. Xto contact the author, Daniel J. Bernstein, at brnstnd@acf10.nyu.edu\n\
  1348. Xon the Internet.\n";
  1349. X
  1350. X#include <stdio.h>
  1351. X#include <sys/types.h>
  1352. X#include <sys/socket.h>
  1353. X#include <netinet/in.h>
  1354. X#include <arpa/inet.h>
  1355. X#include <netdb.h>
  1356. X#include <sys/errno.h>
  1357. Xextern int errno;
  1358. X#include <ctype.h>
  1359. X#include "authuser.h"
  1360. X
  1361. X#ifndef AUTHTCPPORT
  1362. X#define AUTHTCPPORT 113
  1363. X#endif
  1364. X
  1365. X#define SIZ 500 /* various buffers */
  1366. X
  1367. Xint auth_casecmp(u,v)
  1368. Xchar *u;
  1369. Xchar *v;
  1370. X{
  1371. X /* is it correct to consider Foo and fOo the same user? yes */
  1372. X while (*u && *v)
  1373. X   if (tolower(*u) != tolower(*v))
  1374. X     return(tolower(*u) - tolower(*v));
  1375. X   else
  1376. X     u++,v++;
  1377. X return(*u || *v);
  1378. X}
  1379. X
  1380. Xstatic char authline[SIZ];
  1381. X
  1382. Xchar *auth_xline(user,fd,in)
  1383. Xchar *user; /* the supposed name of the user, NULL if unknown */
  1384. Xint fd; /* the file descriptor of the connection */
  1385. Xunsigned long *in;
  1386. X{
  1387. X unsigned short local;
  1388. X unsigned short remote;
  1389. X char *ruser;
  1390. X
  1391. X if (auth_fd(fd,in,&local,&remote) == -1)
  1392. X   return NULL;
  1393. X ruser = auth_tcpuser(*in,local,remote);
  1394. X if (ruser == NULL)
  1395. X   return(NULL);
  1396. X if (user == NULL)
  1397. X   user = ruser; /* forces X-Auth-User */
  1398. X sprintf(authline,
  1399. X     (auth_casecmp(ruser,user) ? "X-Forgery-By: %s" : "X-Auth-User: %s"),
  1400. X     ruser);
  1401. X return(authline);
  1402. X}
  1403. X
  1404. Xint auth_fd(fd,in,local,remote)
  1405. Xint fd;
  1406. Xunsigned long *in;
  1407. Xunsigned short *local;
  1408. Xunsigned short *remote;
  1409. X{
  1410. X struct sockaddr_in sa;
  1411. X int dummy;
  1412. X
  1413. X dummy = sizeof(sa);
  1414. X if (getsockname(fd,&sa,&dummy) == -1)
  1415. X   return -1;
  1416. X if (sa.sin_family != AF_INET)
  1417. X  {
  1418. X   errno = EAFNOSUPPORT;
  1419. X   return -1;
  1420. X  }
  1421. X *local = ntohs(sa.sin_port);
  1422. X dummy = sizeof(sa);
  1423. X if (getpeername(fd,&sa,&dummy) == -1)
  1424. X   return -1;
  1425. X *remote = ntohs(sa.sin_port);
  1426. X *in = sa.sin_addr.s_addr;
  1427. X return 0;
  1428. X}
  1429. X
  1430. Xstatic char ruser[SIZ];
  1431. Xstatic char realbuf[SIZ];
  1432. Xstatic char *buf;
  1433. X
  1434. Xchar *auth_tcpuser(in,local,remote)
  1435. Xunsigned long in;
  1436. Xunsigned short local;
  1437. Xunsigned short remote;
  1438. X{
  1439. X struct sockaddr_in sa;
  1440. X int s;
  1441. X int buflen;
  1442. X int w;
  1443. X int saveerrno;
  1444. X char ch;
  1445. X unsigned short rlocal;
  1446. X unsigned short rremote;
  1447. X
  1448. X if ((s = socket(AF_INET,SOCK_STREAM,0)) == -1)
  1449. X   return(NULL);
  1450. X sa.sin_family = AF_INET;
  1451. X sa.sin_port = htons((unsigned short) AUTHTCPPORT);
  1452. X sa.sin_addr.s_addr = in;
  1453. X if (connect(s,&sa,sizeof(sa)) == -1)
  1454. X  {
  1455. X   saveerrno = errno;
  1456. X   (void) close(s);
  1457. X   errno = saveerrno;
  1458. X   return(NULL);
  1459. X  }
  1460. X
  1461. X buf = realbuf;
  1462. X (void) sprintf(buf,"%u , %u\r\n",(unsigned int) remote,(unsigned int) local);
  1463. X /* note the reversed order */
  1464. X buflen = strlen(buf);
  1465. X while ((w = write(s,buf,buflen)) < buflen)
  1466. X   if (w == -1) /* should we worry about 0 as well? */
  1467. X    {
  1468. X     saveerrno = errno;
  1469. X     (void) close(s);
  1470. X     errno = saveerrno;
  1471. X     return(NULL);
  1472. X    }
  1473. X   else
  1474. X    {
  1475. X     buf += w;
  1476. X     buflen -= w;
  1477. X    }
  1478. X buf = realbuf;
  1479. X while ((w = read(s,&ch,1)) == 1)
  1480. X  {
  1481. X   *buf = ch;
  1482. X   if ((ch != ' ') && (ch != '\t') && (ch != '\r'))
  1483. X     buf++;
  1484. X   if ((buf - realbuf == sizeof(realbuf) - 1) || (ch == '\n'))
  1485. X     break;
  1486. X  }
  1487. X if (w == -1)
  1488. X  {
  1489. X   saveerrno = errno;
  1490. X   (void) close(s);
  1491. X   errno = saveerrno;
  1492. X   return(NULL);
  1493. X  }
  1494. X *buf = '\0';
  1495. X
  1496. X if (sscanf(realbuf,"%hd,%hd: USERID :%*[^:]:%s",
  1497. X            &rremote,&rlocal,ruser) < 3)
  1498. X  {
  1499. X   (void) close(s);
  1500. X   errno = EIO;
  1501. X   /* makes sense, right? well, not when USERID failed to match ERROR */
  1502. X   /* but there's no good error to return in that case */
  1503. X   return(NULL);
  1504. X  }
  1505. X if ((remote != rremote) || (local != rlocal))
  1506. X  {
  1507. X   (void) close(s);
  1508. X   errno = EIO;
  1509. X   return(NULL);
  1510. X  }
  1511. X /* XXXXXX: we're not going to do any backslash processing */
  1512. X (void) close(s);
  1513. X return(ruser);
  1514. X}
  1515. END_OF_FILE
  1516. if test 6556 -ne `wc -c <'authuser.c'`; then
  1517.     echo shar: \"'authuser.c'\" unpacked with wrong size!
  1518. fi
  1519. # end of 'authuser.c'
  1520. fi
  1521. if test -f 'authuser.h' -a "${1}" != "-c" ; then 
  1522.   echo shar: Will not clobber existing file \"'authuser.h'\"
  1523. else
  1524. echo shar: Extracting \"'authuser.h'\" \(279 characters\)
  1525. sed "s/^X//" >'authuser.h' <<'END_OF_FILE'
  1526. X#ifndef AUTHUSER_H
  1527. X#define AUTHUSER_H
  1528. X
  1529. Xextern char authuserauthor[];
  1530. Xextern char authuserversion[];
  1531. Xextern char authusercopyright[];
  1532. Xextern char authuserwarranty[];
  1533. Xextern char authuserhelp[];
  1534. X
  1535. Xint auth_casecmp();
  1536. Xchar *auth_xline();
  1537. Xint auth_fd();
  1538. Xchar *auth_tcpuser();
  1539. X
  1540. X#endif
  1541. END_OF_FILE
  1542. if test 279 -ne `wc -c <'authuser.h'`; then
  1543.     echo shar: \"'authuser.h'\" unpacked with wrong size!
  1544. fi
  1545. # end of 'authuser.h'
  1546. fi
  1547. if test -f 'authuser.man' -a "${1}" != "-c" ; then 
  1548.   echo shar: Will not clobber existing file \"'authuser.man'\"
  1549. else
  1550. echo shar: Extracting \"'authuser.man'\" \(3314 characters\)
  1551. sed "s/^X//" >'authuser.man' <<'END_OF_FILE'
  1552. X.TH authuser 3
  1553. X.SH NAME
  1554. Xauthuser \- remote authentication library using the Authentication Server
  1555. X.SH SYNTAX
  1556. X.B #include <authuser.h>
  1557. X.PP
  1558. X.B int auth_casecmp(u,v);
  1559. X.br
  1560. X.B char *u;
  1561. X.br
  1562. X.B char *v;
  1563. X.PP
  1564. X.B char *auth_xline(user,fd,&in);
  1565. X.PP
  1566. X.B int auth_fd(fd,&in,&local,&remote);
  1567. X.PP
  1568. X.B char *auth_tcpuser(in,local,remote);
  1569. X.PP
  1570. X.B char *user;
  1571. X.br
  1572. X.B int fd;
  1573. X.br
  1574. X.B unsigned long in;
  1575. X.br
  1576. X.B unsigned short local;
  1577. X.br
  1578. X.B unsigned short remote;
  1579. X.SH DESCRIPTION
  1580. XThe
  1581. X.I authuser
  1582. Xlibrary provides a simple interface for
  1583. Xfinding out the remote identity
  1584. Xof a connection through the
  1585. XAuthentication Server
  1586. Xas specified by RFC 931.
  1587. X.PP
  1588. XStatic strings
  1589. X.B authuserauthor[],
  1590. X.B authuserversion[],
  1591. X.B authusercopyright[],
  1592. X.B authuserwarranty[],
  1593. Xand
  1594. X.B authuserhelp[]
  1595. Xcontain the authorship notice,
  1596. Xversion number,
  1597. Xcopyright notice,
  1598. Xwarranty information,
  1599. Xand help notice respectively.
  1600. X.PP
  1601. X.B auth_casecmp(u,v)
  1602. Xreturns 0 if the strings are equal, 1 if the first is larger,
  1603. X-1 if the second is larger. Case is ignored.
  1604. X.PP
  1605. X.B auth_xline(user,fd,&in)
  1606. Xreturns a line of the form X-Auth-User: username or X-Forgery-By: username,
  1607. Xdepending upon what the host on the other side of
  1608. X.B fd
  1609. Xthinks of the user.
  1610. XThis is particularly appropriate for
  1611. Xmail and news headers.
  1612. XThe line is stored in a static area
  1613. Xwhich is overwritten on each call to
  1614. X.B auth_xline.
  1615. XIf 
  1616. X.B fd
  1617. Xis not a TCP connection
  1618. Xor authentication is impossible,
  1619. X.B auth_xline
  1620. Xreturns NULL, setting errno appropriately.
  1621. XIf user is NULL,
  1622. Xit never returns X-Forgery-By.
  1623. XThe line is not cr-lf terminated.
  1624. X.B auth_xline
  1625. Xplaces the Internet address of the other host into in.
  1626. X.PP
  1627. X.B auth_fd(fd,&in,&local,&remote)
  1628. Xretrieves address information from the connection in socket
  1629. X.B fd.
  1630. XIt places the
  1631. XInternet address of the host on other side into
  1632. X.B in
  1633. Xand the local and remote
  1634. XTCP ports into 
  1635. X.B local
  1636. Xand 
  1637. X.B remote.
  1638. X.B auth_fd
  1639. Xreturns -1 upon error, setting errno appropriately.
  1640. X.PP
  1641. X.B auth_tcpuser(in,local,remote)
  1642. Xreturns the name of the user on the other end of the TCP connection
  1643. Xbetween
  1644. X.B remote@in
  1645. Xand
  1646. X.B local.
  1647. XIf authentication is impossible,
  1648. X.B auth_tcpuser
  1649. Xreturns
  1650. XNULL, setting errno appropriately.
  1651. XThe user name is stored in a static area
  1652. Xwhich is overwritten on each call to
  1653. X.B auth_tcpuser
  1654. Xand
  1655. X.B auth_xline.
  1656. X.PP
  1657. X.SH MACHINES
  1658. X.I authuser
  1659. Xhas been tested
  1660. Xon an Astronautics ZS-2
  1661. Xrunning ZSUnix,
  1662. Xa Sun 3 running SunOS, a Sun 4 running SunOS,
  1663. Xa Convex C-210 running Convex UNIX,
  1664. Xand several other machines.
  1665. X.SH RESTRICTIONS
  1666. X.I authuser
  1667. Xdoes no backslash interpretation
  1668. Xupon the remote user name.
  1669. XHopefully the next revision of RFC 931
  1670. Xwill make clear exactly what backslash
  1671. Xinterpretation should be going on.
  1672. X.PP
  1673. X.I authuser
  1674. Xdoes not use the operating system type
  1675. Xinformation provided by the Authentication Server.
  1676. X.SH VERSION
  1677. Xauthuser version 2.0, dated April 2, 1990.
  1678. X.SH AUTHOR
  1679. XCopyright 1990, Daniel J. Bernstein.
  1680. X.SH REFERENCES
  1681. XThe authentication server is more secure than passwords
  1682. Xin some ways, but less secure than passwords in many ways.
  1683. X(It's certainly better than no password at all---e.g., for
  1684. Xmail or news.)
  1685. XIt is not the final solution.
  1686. XFor an excellent discussion of security problems within
  1687. Xthe TCP/IP protocol suite, see
  1688. XSteve Bellovin's article
  1689. X``Security Problems in the TCP/IP Protocol Suite.''
  1690. X.SH "SEE ALSO"
  1691. Xauthtcp(1),
  1692. Xauthd(1),
  1693. Xattachport(1),
  1694. Xtcp(4)
  1695. END_OF_FILE
  1696. if test 3314 -ne `wc -c <'authuser.man'`; then
  1697.     echo shar: \"'authuser.man'\" unpacked with wrong size!
  1698. fi
  1699. # end of 'authuser.man'
  1700. fi
  1701. if test -f 'dir.doc' -a "${1}" != "-c" ; then 
  1702.   echo shar: Will not clobber existing file \"'dir.doc'\"
  1703. else
  1704. echo shar: Extracting \"'dir.doc'\" \(3911 characters\)
  1705. sed "s/^X//" >'dir.doc' <<'END_OF_FILE'
  1706. XThe authentication directory, AUTHDIR/tcp, contains several different
  1707. Xtypes of files.
  1708. X
  1709. XIt is assumed that long ints representing Internet addresses take at
  1710. Xmost ten digits, short ints representing TCP port numbers take at most
  1711. Xfive digits, and ints representing process ids take at most five digits.
  1712. X
  1713. XFiles of the form I.L.R, where I, L, and R are integers, are username
  1714. Xfiles. There is one username file per auth connection to/from this host,
  1715. Xtwo for a local connection. I is the Internet address of the host on the
  1716. Xother end of a TCP connection, expressed as a single long int; L and R
  1717. Xare the connection's local and remote TCP ports respectively. The file
  1718. Xcontains just the name of the user, up to eight characters long.
  1719. X
  1720. XFiles of the form ps.C.P, where C and P are integers, are attachport
  1721. Xprocess files. There is one process file for each connection served by
  1722. Xan attachport on this host. C and P are the process ids of the child
  1723. X(server for a particular connection) and parent (attachport) processes
  1724. Xrespectively. The file contains the name of a username file; in effect,
  1725. Xit points to the username file, so that the attachport can easily keep
  1726. Xtrack of each of its children.
  1727. X
  1728. XFiles of the form lock.L, where L is an integer, are lock files. L is
  1729. Xa local TCP port number. At any time there will be at most one auth
  1730. Xprogram handling connections to/from port L. When authtcp or attachport
  1731. Xstarts, it opens the lock file with O_EXCL and writes its pid into it.
  1732. XIf that fails, it reads the lock file, checks that the process exists,
  1733. Xand gives an appropriate error. When it exits, it removes the lock file.
  1734. X
  1735. XLock files are also used to prevent race conditions during critical
  1736. Xmoments between connecting or accepting a connection and creating the
  1737. Xappropriate username file. For attachport this is no big deal: it
  1738. Xselects for reading before accepting a connection, and from before the
  1739. Xaccept() until the authentication entry is in place, it places an
  1740. Xexclusive flock() on the lock file. (This WILL NOT WORK if selecting
  1741. Xfor reading performs an implicit accept. The race condition resulting
  1742. Xfrom such a bug could be extremely hard to detect; but don't say I
  1743. Xdidn't warn you.) For authtcp, however, this is much more difficult:
  1744. Xan outgoing connect() may take practically forever, and there's no way
  1745. Xto precisely control the moment of connection as a select-accept can.
  1746. XOn the other hand, authtcp has all the local authentication information
  1747. Xit needs, before even beginning the connection. So it writes a colon,
  1748. Xthe I.R remote information, a newline, and the username into the lock
  1749. Xfile after its pid; it doesn't use a flock() except while updating the
  1750. Xlock file. authd will look in this file only if it fails to find a
  1751. Xusername file; authentication requests rarely happen so quickly.
  1752. Xattachport also places extra information into the lock file, namely a
  1753. Xhyphen and the user name.
  1754. X
  1755. XObserve that the duplicate authtcp information in the lock file gives
  1756. Xaway the user name on the local side of a connection that has not yet
  1757. Xsucceeded. Technically, this is not a violation of RFC 931, but it might
  1758. Xoffend purists. Then again, it's symmetric with how the user name is
  1759. Xavailable for a moment after the connection is closed.
  1760. X
  1761. XLatest addition to the lock file: If the first character is a ! then
  1762. Xattachport (or, in a later version, perhaps authtcp) has been killed by
  1763. Xthe user during a critical moment. If you want a detailed explanation of
  1764. Xhow and why this is used, ask auth's author.
  1765. X
  1766. XIf the auth package gets much more complicated, it may be worth imposing
  1767. Xa bit more structure on the authentication directory; hopefully all this
  1768. Xauthentication information will be available from the kernel long before
  1769. Xthat happens. The lock file system would have to be changed immediately
  1770. Xif auth were to support REUSEADDR; however, ftp seems to be the only
  1771. Xprogram that needs REUSEADDR, and PUFF is a much better file transfer
  1772. Xsystem.
  1773. END_OF_FILE
  1774. if test 3911 -ne `wc -c <'dir.doc'`; then
  1775.     echo shar: \"'dir.doc'\" unpacked with wrong size!
  1776. fi
  1777. # end of 'dir.doc'
  1778. fi
  1779. if test -f 'djbatoi.h' -a "${1}" != "-c" ; then 
  1780.   echo shar: Will not clobber existing file \"'djbatoi.h'\"
  1781. else
  1782. echo shar: Extracting \"'djbatoi.h'\" \(381 characters\)
  1783. sed "s/^X//" >'djbatoi.h' <<'END_OF_FILE'
  1784. X/* djbatoi.h, 11/1/89. */
  1785. X
  1786. X#ifndef __DJBATOIH_
  1787. X#define __DJBATOIH_
  1788. X
  1789. X/* some stupid versions of atoi() crash (!) on nulls */
  1790. Xint dummyatoi;
  1791. X#define atoi(s) ( ( dummyatoi = 0 ), \
  1792. X  ( sscanf(s,"%d",&dummyatoi) || ( dummyatoi = 0 ) ), \
  1793. X  dummyatoi )
  1794. Xlong dummyatol;
  1795. X#define atol(s) ( ( dummyatol = 0 ), \
  1796. X  ( sscanf(s,"%D",&dummyatol) || ( dummyatol = 0 ) ), \
  1797. X  dummyatol )
  1798. X
  1799. X#endif
  1800. END_OF_FILE
  1801. if test 381 -ne `wc -c <'djbatoi.h'`; then
  1802.     echo shar: \"'djbatoi.h'\" unpacked with wrong size!
  1803. fi
  1804. # end of 'djbatoi.h'
  1805. fi
  1806. if test -f 'djberr.h' -a "${1}" != "-c" ; then 
  1807.   echo shar: Will not clobber existing file \"'djberr.h'\"
  1808. else
  1809. echo shar: Extracting \"'djberr.h'\" \(491 characters\)
  1810. sed "s/^X//" >'djberr.h' <<'END_OF_FILE'
  1811. X/* djberr.h, 11/1/89. */
  1812. X
  1813. X#ifndef __DJBERRH_
  1814. X#define __DJBERRH_
  1815. X
  1816. Xextern int errno;
  1817. X
  1818. X#define errn(s) (((void) fputs(s,stderr)), putc('\n',stderr))
  1819. X#define err(s) (fputs(s,stderr))
  1820. X#define errn2(s,t) (((void) fprintf(stderr,s,t)), putc('\n',stderr))
  1821. X#define errn3(s,t,u) (((void) fprintf(stderr,s,t,u)), putc('\n',stderr))
  1822. X#define perrn2(s,t) { int dummyerrno = errno; (void) fprintf(stderr,s,t); \
  1823. X              (void) fputs(": ",stderr); errno = dummyerrno; \
  1824. X              (void) perror(""); }
  1825. X
  1826. X#endif
  1827. END_OF_FILE
  1828. if test 491 -ne `wc -c <'djberr.h'`; then
  1829.     echo shar: \"'djberr.h'\" unpacked with wrong size!
  1830. fi
  1831. # end of 'djberr.h'
  1832. fi
  1833. echo shar: End of archive 1 \(of 2\).
  1834. cp /dev/null ark1isdone
  1835. MISSING=""
  1836. for I in 1 2 ; do
  1837.     if test ! -f ark${I}isdone ; then
  1838.     MISSING="${MISSING} ${I}"
  1839.     fi
  1840. done
  1841. if test "${MISSING}" = "" ; then
  1842.     echo You have unpacked both archives.
  1843.     rm -f ark[1-9]isdone
  1844. else
  1845.     echo You still need to unpack the following archives:
  1846.     echo "        " ${MISSING}
  1847. fi
  1848. ##  End of shell archive.
  1849. exit 0
  1850. exit 0 # Just in case...
  1851.